home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 113_01 / a15tbl1.asm < prev    next >
Assembly Source File  |  1985-03-09  |  7KB  |  302 lines

  1.     TITLE    'Machine Language Functions for 1805A Cross-Assembler V 1.2'
  2.     PAGE    60
  3. ;
  4. ;    1805A Cross-Assembler Version 1.2
  5. ;
  6. ;    Copyright (c) 1980, 82, 83, 85 William C. Colley, III.
  7. ;
  8. ;    July 1982 -- Adapted from my 1802 cross-assembler.  WCC3.
  9. ;
  10. ;    Vers 1.0 -- March 1983 -- Added 1805A opcodes to the 1805 set.  WCC3.
  11. ;
  12. ;    Vers 1.1 -- March 1983 -- Added CPU pseudo-op to combine 1802 and 1805A
  13. ;            cross-assemblers into a single program.  WCC3.
  14. ;
  15. ;    Vers 1.2 -- June 1985 -- Fixed IF block nesting mechanism bug and bug
  16. ;            in 1805A SCAL opcode.  WCC3.
  17. ;
  18. ; File:    A15TBL1.ASM
  19. ;
  20. ; Machine Language Functions -- Module #1 of 2.
  21. ;
  22.     MACLIB    CMAC
  23. ;
  24. ; Here I build the directory to the functions in this CRL file:
  25. ;
  26.     DIRECT
  27.     DEFINE    GETOPC        ;First entry.
  28.     DEFINE    NUMOPCS        ;Second entry.
  29.     ENDDIR
  30. ;
  31. ; Arguments are passed via offsets from the stack pointer.
  32. ; They are defined as follows:
  33. ;
  34. ARG0    EQU    2        ;First argument.
  35. ARG1    EQU    4        ;Second argument.
  36. ARG2    EQU    6        ;Third argument.
  37. ARG3    EQU    8        ;Fourth argument.
  38. ;
  39.     PAGE
  40. ;
  41. ; This function gets opcode number num from the opcode table.  The function
  42. ; returns 0 if the opcode was not found, 1 if it was.
  43. ;
  44. ; Function is called as follows:
  45. ;
  46. ;    getopc(num,opcode,value,attrib);
  47. ;
  48. ;    num    Character containing the number of the desired entry.
  49. ;            0 represents the first entry in the table.  The
  50. ;            table is in alphabetical order for the benefit
  51. ;            of the binary searching routine (written in C).
  52. ;    opcode    Pointer to a 5-character array which will receive the
  53. ;            opcode's name (null terminated).
  54. ;    value    Pointer to a character that will receive the opcode's
  55. ;            value.
  56. ;    attrib    Pointer to a character that will receive the opcode's
  57. ;            attibute byte.
  58. ;
  59. NUM    EQU    ARG0
  60. OPCODE    EQU    ARG1
  61. VALUE    EQU    ARG2
  62. ATTRIB    EQU    ARG3
  63. ;
  64.     PRELUDE    GETOPC
  65. ;
  66.     LXI    H, NUM        ;Get entry number.
  67.     DAD    SP
  68.     MOV    A,M
  69.     CPI    OPTBLL        ;Entry in table?
  70.     LXI    H, 0        ;If not, return 0.
  71.     RNC
  72. ;
  73.     MOV    L,A        ;Find entry by computing
  74.     DAD    H        ;  (6 * num) + table base.
  75.     MOV    E,L
  76.     MOV    D,H
  77.     DAD    H
  78.     DAD    D
  79.     RELOC    <LXI D,>,OPCTBL
  80.     DAD    D
  81.     MOV    E,L
  82.     MOV    D,H
  83. ;
  84.     LXI    H, OPCODE    ;Find opcode return area.
  85.     DAD    SP
  86.     MOV    A,M
  87.     INX    H
  88.     MOV    H,M
  89.     MOV    L,A
  90. ;
  91.     PUSH    B        ;Move opcode out to return area.
  92.     MVI    C, 4
  93. MOVOPC:    LDAX    D
  94.     INX    D
  95.     MOV    M,A
  96.     INX    H
  97.     DCR    C
  98.     RELOC    JNZ,MOVOPC
  99.     POP    B
  100. ;
  101.     MVI    M, 0        ;Terminate opcode.
  102. ;
  103.     LXI    H, ATTRIB    ;Find attribute byte return area.
  104.     DAD    SP
  105.     MOV    A,M
  106.     INX    H
  107.     MOV    H,M
  108.     MOV    L,A
  109. ;
  110.     LDAX    D        ;Move attribute byte to return area.
  111.     INX    D
  112.     MOV    M,A
  113. ;
  114.     LXI    H, VALUE    ;Find value byte return area.
  115.     DAD    SP
  116.     MOV    A,M
  117.     INX    H
  118.     MOV    H,M
  119.     MOV    L,A
  120. ;
  121.     LDAX    D        ;Move value byte to return area.
  122.     MOV    M,A
  123. ;
  124.     LXI    H, 1        ;Return 1 for successful get.
  125.     RET
  126. ;
  127. ; The opcode table itself:
  128. ;
  129. ;    Each entry has a four-byte name, a one-byte attribute,
  130. ;    and a one-byte value.  The value is the lowest
  131. ;    numbered opcode having that name.
  132. ;
  133. ;    The attribute byte bits are allocated as follows:
  134. ;
  135. ;        7 = Pseudo-op.
  136. ;        6 = If pseudo-op, if group (no label allowed).
  137. ;        6 = If opcode, 68 group (two-byte opcode).
  138. ;        3-5 = Processor number (0 if pseudo-op).
  139. ;        0-2 = Number of bytes (0 if pseudo-op).
  140. ;
  141. OPCTBL:    DB    'ADC', 0,    01H,    74H
  142.     DB    'ADCI',        12H,    7CH
  143.     DB    'ADD', 0,    01H,    0F4H
  144.     DB    'ADI', 0,    12H,    0FCH
  145.     DB    'AND', 0,    01H,    0F2H
  146.     DB    'ANI', 0,    12H,    0FAH
  147.     DB    'B1', 0, 0,    1AH,    34H
  148.     DB    'B2', 0, 0,    1AH,    35H
  149.     DB    'B3', 0, 0,    1AH,    36H
  150.     DB    'B4', 0, 0,    1AH,    37H
  151.     DB    'BCI', 0,    5BH,    3EH
  152.     DB    'BDF', 0,    1AH,    33H
  153.     DB    'BGE', 0,    1AH,    33H
  154.     DB    'BL', 0, 0,    1AH,    3BH
  155.     DB    'BLK', 0,    80H,    05H
  156.     DB    'BM', 0, 0,    1AH,    3BH
  157.     DB    'BN1', 0,    1AH,    3CH
  158.     DB    'BN2', 0,    1AH,    3DH
  159.     DB    'BN3', 0,    1AH,    3EH
  160.     DB    'BN4', 0,    1AH,    3FH
  161.     DB    'BNF', 0,    1AH,    3BH
  162.     DB    'BNQ', 0,    1AH,    39H
  163.     DB    'BNZ', 0,    1AH,    3AH
  164.     DB    'BPZ', 0,    1AH,    33H
  165.     DB    'BQ', 0, 0,    1AH,    31H
  166.     DB    'BR', 0, 0,    1AH,    30H
  167.     DB    'BXI', 0,    5BH,    3FH
  168.     DB    'BYTE',        80H,    02H
  169.     DB    'BZ', 0, 0,    1AH,    32H
  170.     DB    'CID', 0,    42H,    0DH
  171.     DB    'CIE', 0,    42H,    0CH
  172.     DB    'CPU', 0,    80H,    0DH
  173.     DB    'DACI',        53H,    7CH
  174.     DB    'DADC',        42H,    74H
  175.     DB    'DADD',        42H,    0F4H
  176.     DB    'DADI',        53H,    0FCH
  177.     DB    'DBNZ',        7CH,    20H
  178.     DB    'DEC', 0,    09H,    20H
  179.     DB    'DIS', 0,    01H,    71H
  180.     DB    'DSAV',        42H,    76H
  181.     DB    'DSBI',        53H,    7FH
  182.     DB    'DSM', 0,    42H,    0F7H
  183.     DB    'DSMB',        42H,    77H
  184.     DB    'DSMI',        53H,    0FFH
  185.     DB    'DTC', 0,    42H,    01H
  186.     DB    'ELSE',        0C0H,    07H
  187.     DB    'END', 0,    80H,    06H
  188.     DB    'ENDI',     0C0H,    08H
  189.     DB    'EQU', 0,    80H,    01H
  190.     DB    'ETQ', 0,    42H,    09H
  191.     DB    'GEC', 0,    42H,    08H
  192.     DB    'GHI', 0,    09H,    90H
  193.     DB    'GLO', 0,    09H,    80H
  194.     DB    'IDL', 0,    01H,    00H
  195.     DB    'IF', 0, 0,    0C0H,    09H
  196.     DB    'INC', 0,    09H,    10H
  197.     DB    'INP', 0,    29H,    68H
  198.     DB    'IRX', 0,    01H,    60H
  199.     DB    'LBDF',        23H,    0C3H
  200.     DB    'LBNF',        23H,    0CBH
  201.     DB    'LBNQ',        23H,    0C9H
  202.     DB    'LBNZ',        23H,    0CAH
  203.     DB    'LBQ', 0,    23H,    0C1H
  204.     DB    'LBR', 0,    23H,    0C0H
  205.     DB    'LBZ', 0,    23H,    0C2H
  206.     DB    'LDA', 0,    09H,    40H
  207.     DB    'LDC', 0,    42H,    06H
  208.     DB    'LDI', 0,    12H,    0F8H
  209.     DB    'LDN', 0,    09H,    00H
  210.     DB    'LDX', 0,    01H,    0F0H
  211.     DB    'LDXA',        01H,    72H
  212.     DB    'LOAD',        80H,    0CH
  213.     DB    'LSDF',        01H,    0CFH
  214.     DB    'LSIE',        01H,    0CCH
  215.     DB    'LSKP',        01H,    0C8H
  216.     DB    'LSNF',        01H,    0C7H
  217.     DB    'LSNQ',        01H,    0C5H
  218.     DB    'LSNZ',        01H,    0C6H
  219.     DB    'LSQ', 0,    01H,    0CDH
  220.     DB    'LSZ', 0,    01H,    0CEH
  221.     DB    'MARK',        01H,    79H
  222.     DB    'NBR', 0,    1AH,    38H
  223.     DB    'NLBR',        23H,    0C8H
  224.     DB    'NOP', 0,    01H,    0C4H
  225.     DB    'OR', 0, 0,    01H,    0F1H
  226.     DB    'ORG', 0,    80H,    00H
  227.     DB    'ORI', 0,    12H,    0F9H
  228.     DB    'OUT', 0,    29H,    60H
  229.     DB    'PAGE',        80H,    0BH
  230.     DB    'PHI', 0,    09H,    0B0H
  231.     DB    'PLO', 0,    09H,    0A0H
  232.     DB    'REQ', 0,    01H,    7AH
  233.     DB    'RET', 0,    01H,    70H
  234.     DB    'RLDI',        74H,    0C0H
  235.     DB    'RLXA',        4AH,    60H
  236.     DB    'RNX', 0,    4AH,    0B0H
  237.     DB    'RSHL',        01H,    7EH
  238.     DB    'RSHR',        01H,    76H
  239.     DB    'RSXD',        4AH,    0A0H
  240.     DB    'SAV', 0,    01H,    78H
  241.     DB    'SCAL',        74H,    80H
  242.     DB    'SCM1',        42H,    05H
  243.     DB    'SCM2',        42H,    03H
  244.     DB    'SD', 0, 0,    01H,    0F5H
  245.     DB    'SDB', 0,    01H,    75H
  246.     DB    'SDBI',        12H,    7DH
  247.     DB    'SDI', 0,    12H,    0FDH
  248.     DB    'SEP', 0,    09H,    0D0H
  249.     DB    'SEQ', 0,    01H,    7BH
  250.     DB    'SET', 0,    80H,    0AH
  251.     DB    'SEX', 0,    09H,    0E0H
  252.     DB    'SHL', 0,    01H,    0FEH
  253.     DB    'SHLC',        01H,    7EH
  254.     DB    'SHR', 0,    01H,    0F6H
  255.     DB    'SHRC',        01H,    76H
  256.     DB    'SKP', 0,    01H,    38H
  257.     DB    'SM', 0, 0,    01H,    0F7H
  258.     DB    'SMB', 0,    01H,    77H
  259.     DB    'SMBI',        12H,    7FH
  260.     DB    'SMI', 0,    12H,    0FFH
  261.     DB    'SPM1',        42H,    04H
  262.     DB    'SPM2',        42H,    02H
  263.     DB    'SRET',        4AH,    90H
  264.     DB    'STM', 0,    42H,    07H
  265.     DB    'STPC',        42H,    00H
  266.     DB    'STR', 0,    09H,    50H
  267.     DB    'STXD',        01H,    73H
  268.     DB    'TEXT',        80H,    04H
  269.     DB    'WORD',        80H,    03H
  270.     DB    'XID', 0,    42H,    0BH
  271.     DB    'XIE', 0,    42H,    0AH
  272.     DB    'XOR', 0,    01H,    0F3H
  273.     DB    'XRI', 0,    12H,    0FBH
  274. ;
  275. OPTBLL    EQU    ($-OPCTBL)/6    ;Calculate length of table.
  276. ;
  277.     POSTLUDE GETOPC
  278. ;
  279.     PAGE
  280. ;
  281. ; This function returns the number of opcodes in the opcode table
  282. ; for the benefit of the binary searching routine (written in C).
  283. ;
  284. ; This function is called as follows:
  285. ;
  286. ;    numopcs();
  287. ;
  288.     PRELUDE    NUMOPCS
  289. ;
  290.     LXI    H, OPTBLL    ;Return number of opcodes.
  291.     RET
  292. ;
  293.     POSTLUDE NUMOPCS
  294. ;
  295. ; End of package:
  296. ;
  297.     END
  298.  0,    09H,    0D0H
  299.     DB    'SEQ', 0,    01H,    7BH
  300.     DB    'SET', 0,    80H,    0AH
  301.     DB    'SEX', 0,    09H,    0E0H
  302.     DB    'SHL'